/**
 * 兼容老版本的iframe组件
 */

import React from 'react';
import { connect } from 'react-redux';
import { OLD_VERSION_HOST } from '../../schema/constants';

import { setTitle } from '../actions/topAction';

import * as InnerWindowStyle from './InnerWindow.less';

class InnerWindow extends React.Component {
	constructor(props) {
		super(props);
	}

	render() {
		let { location } = this.props;

		if (/^\/app\/([\w|\/|-|\.]+)$/igm.test(location.pathname)) {
			return (<iframe border='0' frameBorder='no' marginWidth='0' className={InnerWindowStyle.window} src={`${OLD_VERSION_HOST}/${RegExp.$1}`}></iframe>);
		} else {
			return (<div>404 页面就这么不见了~</div>);
		}
	}
}

export default connect((state)=>({location: state.router.location}))(InnerWindow);